﻿namespace Sidvall.LogManager.Net.Services.V1.Model
{
    public class ResourceFactory : global::Sidvall.Data.IResourceFactory
    {
        #region CreateItem

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItem(string resource, Sidvall.Data.DataRowState? dataRowState)
        {
            switch (resource)
            {
                case global::Sidvall.LogManager.Data.Model.DomainObjects.LogScope:
                    return new global::Sidvall.LogManager.Net.Services.V1.LogScope(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.LogManager.Data.Model.DomainObjects.LogScopeItem:
                    return new global::Sidvall.LogManager.Net.Services.V1.LogScopeItem(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.LogManager.Data.Model.DomainObjects.LogScopeItemCategory:
                    return new global::Sidvall.LogManager.Net.Services.V1.LogScopeItemCategory(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                default:
                    return null;
            }
        }

        #endregion
        #region CreateItems

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItems(string resource)
        {
            switch (resource)
            {
                case global::Sidvall.LogManager.Data.Model.DomainObjects.LogScope:
                    return new global::Sidvall.LogManager.Net.Services.V1.LogScopeCollectionItem();
                case global::Sidvall.LogManager.Data.Model.DomainObjects.LogScopeItem:
                    return new global::Sidvall.LogManager.Net.Services.V1.LogScopeItemCollectionItem();
                case global::Sidvall.LogManager.Data.Model.DomainObjects.LogScopeItemCategory:
                    return new global::Sidvall.LogManager.Net.Services.V1.LogScopeItemCategoryCollectionItem();
                default:
                    return null;
            }
        }
        
        #endregion
        
        #region Current

        private static readonly System.Lazy<ResourceFactory> _Current = new System.Lazy<ResourceFactory>(() => new ResourceFactory());
        public static ResourceFactory Current
        {
            get
            {
                return _Current.Value;
            }
        }

        #endregion
    }
}